using System;
using System.Diagnostics.CodeAnalysis;

namespace iPhOwa.Exchange.Attributes
{
	/// <summary>
	/// Attribute to be applied to classes to specify the Exchange content class of the object.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
	public sealed class ExchangeContentClassAttribute : Attribute
	{
		private readonly string fullName;

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="fullName">Set the full name.</param>
		/// <exception cref="ArgumentException">Throws if <paramref name="fullName"/> does not start with "urn:content-classes:".</exception>
		/// <exception cref="ArgumentNullException">Throws if <paramref name="fullName"/> is null.</exception>
		[SuppressMessage("Microsoft.Globalization", "CA1309:UseOrdinalStringComparison", MessageId = "System.String.StartsWith(System.String,System.StringComparison)")]
		public ExchangeContentClassAttribute(string fullName)
		{
			if(fullName == null)
			{
				throw new ArgumentNullException("fullName");
			}
			else if(!fullName.StartsWith("urn:content-classes:", StringComparison.InvariantCultureIgnoreCase))
			{
				throw new ArgumentException("fullName must start with 'urn:content-classes:'.", "fullName");
			}

			this.fullName = fullName;
		}

		/// <summary>
		/// The fully qualitfied name of the content class.
		/// </summary>
		public string FullName
		{
			get { return fullName; }
		}
	}
}